In [ ]:
#%%
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.dates as mdate
from matplotlib.pyplot import rcParams 
from PIL import Image 
import PIL 
In [ ]:
# natural population growth data
population = pd.read_csv('../../data/01-modified-data/cleaned-population-py.csv')

population = population.drop(columns=['Unnamed: 0'])
population['Deaths']=np.log10(population['Deaths'])
population['Births']=np.log10(population['Births'])
population['GDP']=np.log10(population['GDP'])
population.head()
Out[ ]:
Entity Year Natural_growth_rate GDP Deaths Births
0 Afghanistan 2002 3.69 3.075468 5.360688 5.991429
1 Afghanistan 2003 3.67 3.091952 5.380600 6.026634
2 Afghanistan 2004 3.61 3.079282 5.386262 6.040270
3 Afghanistan 2005 3.53 3.109509 5.382834 6.041142
4 Afghanistan 2006 3.50 3.119186 5.391000 6.055674
In [ ]:
population.set_index('Year', inplace=True)
In [ ]:
#population.groupby('Entity')['Natural_growth_rate'].plot(legend=True, figsize=(20, 5))
population.groupby('Entity').plot(legend=True, figsize=(20, 5))
#growth = pd.concat( [ gb.get_group(group) for i,group in enumerate( gb.groups) if i < 5 ] ).groupby('Entity')
#growth.plot(legend=True, figsize=(20, 5))
c:\Users\Shenghao\anaconda3\envs\ANLY501\lib\site-packages\pandas\plotting\_matplotlib\core.py:386: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  fig = self.plt.figure(figsize=self.figsize)
Out[ ]:
Entity
Afghanistan            AxesSubplot(0.125,0.11;0.775x0.77)
Albania                AxesSubplot(0.125,0.11;0.775x0.77)
Algeria                AxesSubplot(0.125,0.11;0.775x0.77)
Angola                 AxesSubplot(0.125,0.11;0.775x0.77)
Antigua and Barbuda    AxesSubplot(0.125,0.11;0.775x0.77)
                                      ...                
Vanuatu                AxesSubplot(0.125,0.11;0.775x0.77)
Vietnam                AxesSubplot(0.125,0.11;0.775x0.77)
World                  AxesSubplot(0.125,0.11;0.775x0.77)
Zambia                 AxesSubplot(0.125,0.11;0.775x0.77)
Zimbabwe               AxesSubplot(0.125,0.11;0.775x0.77)
Length: 195, dtype: object